package amani.wechat.platform.services.impl;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.jws.WebMethod;

import org.apache.commons.lang3.StringUtils;
//import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import amani.wechat.platform.controller.model.ActivateCard;
import amani.wechat.platform.services.ICommonService;
import amani.wechat.platform.webserviceClient.Account;
import amani.wechat.platform.webserviceClient.AnyType2AnyTypeMap;
import amani.wechat.platform.webserviceClient.ArrayOfAnyType2AnyTypeMap;
import amani.wechat.platform.webserviceClient.ArrayOfSpadDconsumeInfo;
import amani.wechat.platform.webserviceClient.Cardinfo;
import amani.wechat.platform.webserviceClient.CategoryinfoId;
import amani.wechat.platform.webserviceClient.CommonServicePortType;
import amani.wechat.platform.webserviceClient.Companyinfo;
import amani.wechat.platform.webserviceClient.Evaluation;
import amani.wechat.platform.webserviceClient.Goodsinfo;
import amani.wechat.platform.webserviceClient.Nointernalcardinfo;
import amani.wechat.platform.webserviceClient.Projectinfo;
import amani.wechat.platform.webserviceClient.Roominfo;
import amani.wechat.platform.webserviceClient.SpadDconsumeInfo;
import amani.wechat.platform.webserviceClient.SpadMconsumeInfo;
import amani.wechat.platform.webserviceClient.StaffHairDesignerInfo;
import amani.wechat.platform.webserviceClient.Staffinfo;
import amani.wechat.platform.webserviceClient.VirtualCard;
import amani.wechat.platform.webserviceClient.Vouchersdetal;
import amani.wechat.platform.webserviceClient.Wxbandcard;

import com.jianzhou.sdk.BusinessService;
import com.sun.org.apache.xerces.internal.dom.ElementNSImpl;

@Service("CommonService")
public class CommonService implements ICommonService {
	//private static Logger logger = Logger.getLogger(ConfigurationService.class);
	private static CommonServicePortType commonserviceProxy;

	static {
		amani.wechat.platform.webserviceClient.CommonService cs = new amani.wechat.platform.webserviceClient.CommonService();
		commonserviceProxy = cs.getCommonServiceHttpPort();
	}

		private static BusinessService aBusinessService;
		static{
			aBusinessService = new BusinessService();
			aBusinessService.setWebService("http://www.jianzhou.sh.cn/JianzhouSMSWSServer/services/BusinessService");
		}
		
	public CommonService() {

	}
	
	@Override
	public boolean updtaeCardCodeState(String cardCode,int state){
		return commonserviceProxy.updtaeCardCodeState(cardCode, state);
	}
	
	@Override
	public boolean updtaeOrderStateByCardCode(String cardCode,int orderState){
		return commonserviceProxy.updtaeOrderStateByCardCode(cardCode, orderState);
	}
	
	@Override
	public boolean updtaeOrderCard(String orderno,String cardId,String cardCode){
		return commonserviceProxy.updtaeOrderCard(orderno, cardId, cardCode);
	}

	@Override
	public boolean updtaeOrderStateByOrderNo(String orderno,String OrderType,int orderState){
		return commonserviceProxy.updtaeOrderStateByOrderNo(orderno, OrderType, orderState);
	}
	
	@Override
	public int getOrderStateByOrderNo(String orderno,String OrderType){
		return commonserviceProxy.getOrderStateByOrderNo(orderno, OrderType);
	}

	@Override
	public String getCardcode(String cardId){
		return commonserviceProxy.getCardcode(cardId);
	}
	
	@Override
	public  List<Map<String, Object>> getNewsListByCid( String cid){
		ArrayOfAnyType2AnyTypeMap arrayMap= commonserviceProxy.getNewsListByCid(cid); 
		
		return ToListMap(arrayMap);
	}
	
	@Override
	public Map<String, Object> getNewsById( String id){
		AnyType2AnyTypeMap map= commonserviceProxy.getNewsById(id); 
		return ToMap(map); 
	}

	
	public Map<String, Object> loadWxOrderByOrderNo(String orderno){
		AnyType2AnyTypeMap map=  commonserviceProxy.loadWxOrderByOrderNo(orderno);
		if(map!=null){
			return ToMap(map); 
		}else{
			return null;
		}
	} 
	@Override
	public Companyinfo loadCompanyinfo(String strCompId) {
		return commonserviceProxy.loadCompanyinfo(strCompId);
	}

	@Override
	public List<Companyinfo> loadAllCompanyinfo() {
		return commonserviceProxy.loadAllCompanyinfo().getCompanyinfo();
	}

	@Override
	public List<Projectinfo> loadProjectinfo(String strCompId) {
		return commonserviceProxy.loadProjectinfo(strCompId).getProjectinfo();
	}

	@Override
	public List<Goodsinfo> loadAllGoodinfo() {
		return commonserviceProxy.loadAllGoodinfo().getGoodsinfo();
	}

	@Override
	public String loadStaffinfo(String strCompId, String itemNo) {

		return commonserviceProxy.loadStaffinfo(strCompId, itemNo);
	}

	@Override
	public List<CategoryinfoId> loadCategory(String strCompId) {

		return commonserviceProxy.loadCategory(strCompId).getCategoryinfoId();
	}

	@Override
	public List<Roominfo> loadRoomInfo(String strCompId) {

		return commonserviceProxy.loadRoomInfo(strCompId).getRoominfo();
	}

	@Override
	public List<String> loadMirror(String strCompId) {

		return commonserviceProxy.loadMirror(strCompId).getString();
	}

	@Override
	public List<Cardinfo> loadCardInfos(String strPhone, String strCardNo) {

		return commonserviceProxy.loadCardInfos(strPhone, strCardNo)
				.getCardinfo();
	}

	@Override
	public Cardinfo loadCardInfo(String strCompId, String strCardNo) {

		return commonserviceProxy.loadCardInfo(strCompId, strCardNo);
	}

	@Override
	public boolean saveIPADBillInfo(SpadMconsumeInfo spadMconsumeInfo,
			List<SpadDconsumeInfo> spadDconsumeInfo) {
		ArrayOfSpadDconsumeInfo spadDconsumeInfoArray = new ArrayOfSpadDconsumeInfo();
		spadDconsumeInfoArray.getSpadDconsumeInfo().addAll(spadDconsumeInfo);
		return commonserviceProxy.saveIPADBillInfo(spadMconsumeInfo,
				spadDconsumeInfoArray);
	}

	@Override
	public String loadVouchers() {

		return commonserviceProxy.loadVouchers();
	}

	@Override
	public String loadDqyNo(String strOpenId, String strClientName,
			String strMobile, String strVchNo, String strBillId) {

		return commonserviceProxy.loadDqyNo(strOpenId, strClientName,
				strMobile, strVchNo, strBillId);
	}

	@Override
	public String loadCardAccount(String strCardNo) {

		return commonserviceProxy.loadCardAccount(strCardNo);
	}

	@Override
	public String loadCardproaccounts(String strCompId, String strCardNo) {

		return commonserviceProxy.loadCardproaccounts(strCompId, strCardNo);
	}

	@Override
	public String loadcCardaccountchangehistories(String strCardNo) {

		return commonserviceProxy.loadcCardaccountchangehistories(strCardNo);
	}

	@Override
	public boolean updateCardPassword(String strCardNo, String strPassword) {

		return commonserviceProxy.updateCardPassword(strCardNo, strPassword);
	}

	@Override
	public boolean checkCardPassword(String strCardNo, String strPassword) {

		return commonserviceProxy.checkCardPassword(strCardNo, strPassword);
	}

	@Override
	public List<Vouchersdetal> loadVouchersdetalsById(String strVchNo) {

		return commonserviceProxy.loadVouchersdetalsById(strVchNo)
				.getVouchersdetal();
	}

	@Override
	public Wxbandcard loadWxbandcard(String strCardNo, String strOperId) {

		return commonserviceProxy.loadWxbandcard(strCardNo, strOperId);
	}

	@Override
	public boolean checkDyqNo(String strDyqNo) {

		return commonserviceProxy.checkDyqNo(strDyqNo);
	}

	@Override
	public String lsDnointernalcardinfos(String strDyqNo) {

		return commonserviceProxy.lsDnointernalcardinfos(strDyqNo);
	}

	@Override
	public Nointernalcardinfo loadNointernalcardinfo(String strDyqNo) {

		return commonserviceProxy.loadNointernalcardinfo(strDyqNo);
	}

	@Override
	public String loadwWeixinclents(String strOperId) {

		return commonserviceProxy.loadwWeixinclents(strOperId);
	}

	@Override
	public boolean wxPost(String strCompId, String strBillId, String strDate) {

		return commonserviceProxy.wxPost(strCompId, strBillId, strDate);
	}

	@Override
	public boolean saveEvaluation(String billid, String operid,
			double discount, String content, double amt) {

		return commonserviceProxy.saveEvaluation(billid, operid, discount,
				content, amt);
	}

	@Override
	public Evaluation loadEvaluation(String operid, String billid) {

		return commonserviceProxy.loadEvaluation(operid, billid);
	}

	@Override
	public boolean saveOrders(String strCompId, String strBillId,
			String strCardNo, String orderPhone, String strDate,
			String strTime, String openid, int billType, String complydetail) {

		return commonserviceProxy.saveOrders(strCompId, strBillId, strCardNo,
				orderPhone, strDate, strTime, openid, billType, complydetail);
	}

	@Override
	public boolean saveOrderPrjInfo(String strCompId, String strBillId,
			String strPrjInfo, String strPrjName) {

		return commonserviceProxy.saveOrderPrjInfo(strCompId, strBillId,
				strPrjInfo, strPrjName);
	}

	@Override
	public boolean saveOrderEmpInfo(String strCompId, String strBillId,
			String strEmpNo, String strEmpName, String strEmpInid) {

		return commonserviceProxy.saveOrderEmpInfo(strCompId, strBillId,
				strEmpNo, strEmpName, strEmpInid);
	}

	@Override
	public String loadOrders(String openid) {

		return commonserviceProxy.loadOrders(openid);
	}

	@Override
	public String loadCompByCardNo(String strCardNo) {

		return commonserviceProxy.loadCompByCardNo(strCardNo);
	}

	@Override
	public String loadEmpInfoByComp(String strCompId, String strCardNo) {

		return commonserviceProxy.loadEmpInfoByComp(strCompId, strCardNo);
	}

	@Override
	public String loadEmpInfoByDept(String strCompId) {

		return commonserviceProxy.loadEmpInfoByDept(strCompId);
	}

	@Override
	public boolean updBillState(String strCompId, String strBillId) {

		return commonserviceProxy.updBillState(strCompId, strBillId);
	}

	@Override
	public boolean updOrderState(String strBillId) {

		return commonserviceProxy.updOrderState(strBillId);
	}

	@Override
	public String checkBillState(String strBillId) {

		return commonserviceProxy.checkBillState(strBillId);
	}

	@Override
	public boolean bandStaffInfo(String strParams) {

		return commonserviceProxy.bandStaffInfo(strParams);
	}

	@Override
	public String saveNewOrders(String strCompId, String strBillId,
			String strItemNo, String strEmpNo, int ispz, String strDate,
			String strTime, String orderPhone, String strCardNo, String openid,
			String strEmpName) {

		return commonserviceProxy.saveNewOrders(strCompId, strBillId,
				strItemNo, strEmpNo, ispz, strDate, strTime, orderPhone,
				strCardNo, openid, strEmpName);
	}

	@Override
	public String loadOrderDetal(String openid) {

		return commonserviceProxy.loadOrderDetal(openid);
	}

	@Override
	public String loadOrderById(String callbillid) {

		return commonserviceProxy.loadOrderById(callbillid);
	}

	@Override
	public String loadOrderByEmp(String strCompId, String strEmpNo,
			String orderDate, String orderTime) {

		return commonserviceProxy.loadOrderByEmp(strCompId, strEmpNo,
				orderDate, orderTime);
	}

	@Override
	public String loadOrderByOpenId(String openId, String orderDate,
			String orderTime) {

		return commonserviceProxy.loadOrderByOpenId(openId, orderDate,
				orderTime);
	}

	@Override
	public String loadNewEmpInfoByComp(String strCompId, String strCardNo,
			int billtype) {

		return commonserviceProxy.loadNewEmpInfoByComp(strCompId, strCardNo,
				billtype);
	}

	@Override
	public String loadStartHairInfo(String strCompId) {

		return commonserviceProxy.loadStartHairInfo(strCompId);
	}

	@Override
	public String loadStartBeautyInfo(String strCompId) {

		return commonserviceProxy.loadStartBeautyInfo(strCompId);
	}

	@Override
	public String checkUser(String strCompId, String userName, String pwd) {

		return commonserviceProxy.checkUser(strCompId, userName, pwd);
	}

	@Override
	public String saveInventory(String strCompId, String userId,
			String strParams) {
		return commonserviceProxy.saveInventory(strCompId, userId, strParams);
	}

	@Override
	public String addInventory(String strCompId) {

		return commonserviceProxy.addInventory(strCompId);
	}

	@Override
	public String checkGoodBar(String strCompId, String strGoodBar) {

		return commonserviceProxy.checkGoodBar(strCompId, strGoodBar);
	}

	@Override
	public String deleteInventoryByInventBill(String strCompId,
			String inventBill) {
		return commonserviceProxy.deleteInventoryByInventBill(strCompId,
				inventBill);
	}

	@Override
	public String deleteInventoryByBill(String strCompId, String bill) {

		return commonserviceProxy.deleteInventoryByBill(strCompId, bill);
	}

	@Override
	public String findGoodBarInfo(String goodBarNo) {
		return commonserviceProxy.findGoodBarInfo(goodBarNo);
	}

	@Override
	public List<Map<String, Object>> loadHotProducts() { 
		ArrayOfAnyType2AnyTypeMap arrayMap= commonserviceProxy.loadHotProducts();
		return ToListMap(arrayMap); 
	}
	
	
//	//到店首页美发作品数据获取
//	@Override
//	public List<Map<String, Object>> pageWorks(int begin,int end){
//		ArrayOfAnyType2AnyTypeMap arrayMap= commonserviceProxy.pageWorks(begin,end); 
//		return ToListMap(arrayMap); 
//	}
//	
//	//美发作品页面作品数据获取
//	@Override
//	public Map<String, Object> loadWorks(int id){
//
//		AnyType2AnyTypeMap map= commonserviceProxy.loadWorks(id); 
//		return ToMap(map); 
//	}
	
	//美发作品页面设计师数据获取
//	@Override
//	public List<Map<String, Object>> loadStaffinfo1(String staffopenid ){ 
//		ArrayOfAnyType2AnyTypeMap arrayMap= commonserviceProxy.loadStaffinfo1(staffopenid); 
//		return ToListMap(arrayMap); 
//	}
	
	//美发作品页面设计师美发作品数据获取
//	@Override
//	public List<Map<String, Object>> pageWorksByDesigner(int begin,int end,String staffopenid){ 
//		ArrayOfAnyType2AnyTypeMap arrayMap= commonserviceProxy.pageWorksByDesigner(begin,end,staffopenid); 
//		return ToListMap(arrayMap); 
//	}
//	
//	//到店页面美容项目数据获取
//	@Override
//	public List<Map<String, Object>> loadAllProject(){
//		ArrayOfAnyType2AnyTypeMap arrayMap= commonserviceProxy.loadAllProject(); 
//		return ToListMap(arrayMap); 
//	}
//	
//	//到店页面美容项目数据获取
//	@Override
//	public List<Map<String, Object>> loadProjectByType(String type){
//
//		ArrayOfAnyType2AnyTypeMap arrayMap= commonserviceProxy.loadProjectByType(type); 
//		return ToListMap(arrayMap); 
//	}
	
	/**
	 * 根据产品id（wx_product.id），查询产品信息
	 * @param productId
	 * @return
	 */
	@Override
	public Map<String,Object> loadWchatProduct(String productId){
		AnyType2AnyTypeMap arrayMap = commonserviceProxy.loadWchatProduct(productId);
		return  ToMap(arrayMap); 
	}
	 
	/**
	 * 根据产品id（wx_product.id），查询详细步骤数据
	 * @param productId
	 * @return
	 */
	@Override
	public List<Map<String,Object>> loadProductDetail(String productId){
		ArrayOfAnyType2AnyTypeMap arrayMap= commonserviceProxy.loadProductDetail(productId); 
		return ToListMap(arrayMap);
	}
	
	/**
	 * 根据产品id（wx_product.id），查询套餐数据
	 * @param productId
	 * @return
	 */
	@Override
	public List<Map<String,Object>> loadProductPackage(String productId){
		ArrayOfAnyType2AnyTypeMap arrayMap= commonserviceProxy.loadProductPackage(productId); 
		return ToListMap(arrayMap);
	}


	/**
	 * 获取指定openid预约过的设计师
	 * @param openid 
	 * @param projecttype 001(头发) 004(身体) 005(面部)
	 * @return
	 */
	@Override
	public List<Map<String, Object>>  loadConsumedStaffinfos(String openid,String projecttype){ 
		ArrayOfAnyType2AnyTypeMap arrayMap= commonserviceProxy.loadConsumedStaffinfos(openid,projecttype); 
		return ToListMap(arrayMap);
	}
	/**
	 * 获取门面的前N位员工
	 * @param compno 门面id
	 * @param projecttype 类型001(头发) 004(身体) 005(面部)
	 * @param n 
	 * @return
	 */
	@Override
	public List<Map<String, Object>>  loadStaffinfosByCompno(String compno,String projecttype,int n){
		ArrayOfAnyType2AnyTypeMap arrayMap= commonserviceProxy.loadStaffinfosByCompno(compno,projecttype,n); 
		return ToListMap(arrayMap);
	} 
	
	/**
	 * 根据openid获取会员卡信息
	 * @param openid openid
	 * @return
	 */
	@Override
	public List<Map<String, Object>>  loadMemberinfoByOpenid(String openid){
		ArrayOfAnyType2AnyTypeMap arrayMap= commonserviceProxy.loadMemberinfoByOpenid(openid); 
		return ToListMap(arrayMap);
	}
	
	
	/**
	 * 保存微信订单数据第一步
	 * @param isExpress
	 * @param orderno
	 * @param price
	 * @param openid
	 * @param memberno
	 * @param address
	 * @param username
	 * @param phone
	 * @param compno
	 * @param compname
	 * @param companyaddress
	 * @return
	 */ 
	public int saveWxOrderStep1(boolean isExpress,String orderno,double price,String openid,String memberno, String address,String username,String phone,String compno,String compname,String companyaddress){
		return commonserviceProxy.saveWxOrderStep1(isExpress, orderno, price, openid, memberno, address, username, phone, compno, compname, companyaddress);
	}
	
	
	/**
	 * 保存微信订单数据第二步
	 * @param parentId
	 * @param produectId
	 * @param number
	 */
	public void saveWxOrderStep2(int parentId, int produectId,int number){
		 commonserviceProxy.saveWxOrderStep2(parentId,produectId,number);
	}

	/**
	 * 加载商品描述信息
	 * @param produectId
	 * @return
	 */
	public List<Map<String, Object>> loadProductDescription(String produectId){
		ArrayOfAnyType2AnyTypeMap arrayMap= commonserviceProxy.loadProductDescription(produectId); 
		return ToListMap(arrayMap);
	}
	
	/**
	 * 加载商品信息
	 * @param produectId
	 * @return
	 */
	public List<Map<String, Object>> loadProductInfo(String produectId){
		ArrayOfAnyType2AnyTypeMap arrayMap= commonserviceProxy.loadProductInfo(produectId); 
		return ToListMap(arrayMap);
	}


	/**
	 * 加载商品分类下的商品信息
	 * @param goupId
	 * @return
	 */
	public List<Map<String, Object>> loadProductsByGroupId(String goupId){
		ArrayOfAnyType2AnyTypeMap arrayMap= commonserviceProxy.loadProductsByGroupId(goupId); 
		return ToListMap(arrayMap);
	}

	/**
	 * 加载商品分类
	 * @return
	 */
	public List<Map<String, Object>> loadProductGroup(){
		ArrayOfAnyType2AnyTypeMap arrayMap= commonserviceProxy.loadProductGroup(); 
		return ToListMap(arrayMap);
	}

	
	private List<Map<String,Object>>  ToListMap(ArrayOfAnyType2AnyTypeMap arrayMap){
		List<Map<String,Object>> listMap=new ArrayList<Map<String,Object>>();
	    List<AnyType2AnyTypeMap> list=	arrayMap.getAnyType2AnyTypeMap();
		for(int i=0;i<list.size();i++){
			List<AnyType2AnyTypeMap.Entry> listEntry=list.get(i).getEntry();
			Map<String,Object> tempMap=new HashMap<String,Object>();
			for(int j=0;j<listEntry.size();j++){
				Object val = listEntry.get(j).getValue();
				if(val instanceof ElementNSImpl)
					val = null;
				tempMap.put((String)listEntry.get(j).getKey(), val);
			}
			listMap.add(tempMap);
		}
		return listMap;
	}
	
	private Map<String,Object> ToMap(AnyType2AnyTypeMap arrayMap){
		Map<String,Object> tempMap=new HashMap<String,Object>();
		List<AnyType2AnyTypeMap.Entry> listEntry=arrayMap.getEntry();
		for(int j=0;j<listEntry.size();j++){
			Object val = listEntry.get(j).getValue();
			if(val instanceof ElementNSImpl)
				val = null;
			tempMap.put((String)listEntry.get(j).getKey(), val);
		} 
		return tempMap;
	}

	public synchronized String sendMessage(String phone,String message){
		String acount = commonserviceProxy.loadSysParam("001", "SP069");
		String password = commonserviceProxy.loadSysParam("001", "SP070");
		int a = aBusinessService.sendMessage("sdk_amani88", "20140224", phone, message);
		System.out.println(a);
		return "";
	}
	
	public boolean bindingCard(String cardno,String name,String phone,String openid){
		return commonserviceProxy.bindingCard(cardno, name, phone, openid);
	}
	
	/**
	 * 按照openId查找员工信息
	 * @param openId
	 * @return
	 */
	public Staffinfo findStaffinfo(String openId){
		return commonserviceProxy.findStaffinfoByOpenId(openId);
	}

	@Override
	public boolean saveStaffHairDesignerInfo(Integer id, String lx, String bq,
			String ms, String openid, String imageUrl) {
		return commonserviceProxy.saveStaffHairDesignerInfo(id, lx, bq, ms, openid, imageUrl);
	}

	@Override
	public List<StaffHairDesignerInfo> loadStaffHairDesignerInfo(String openid) {
		return commonserviceProxy.loadStaffHairDesignerInfo(openid).getStaffHairDesignerInfo();
	}

	@Override
	public boolean updateStaffInfo(String openid, String staffename,
			String imageurl) {
		return commonserviceProxy.updateStaffInfo(openid, staffename, imageurl);
	}
	
	public StaffHairDesignerInfo findStaffHairDesignerInfo(Integer id){
		return commonserviceProxy.findStaffHairDesignerInfo(id);
	}
	
	public VirtualCard saveVirtualCard(String openId,String phone,int sex){
		return commonserviceProxy.saveVirtualCard(openId, phone, sex);
	}

	@Override
	public String getStaffWorkDay(String year, String month, String openId) {
		String begin = year+"-"+month+"-01";
		String end = year+"-"+month+"-01";
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");  
	    try {
			Date date = sdf.parse(begin);
			Calendar calender = Calendar.getInstance();
	        calender.setTime(date);
	        begin = sdf.format(calender.getTime());
	        calender.add(Calendar.MONTH, 1);
	        end =  sdf.format(calender.getTime());
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return commonserviceProxy.getStaffWorkDay(begin, end, openId);
	}

	@Override
	public boolean saveStaffRestDay(String openId, String date) {
		return commonserviceProxy.saveStaffRestDay(openId, date);
	}
	
	public String getOrders(String year, String month,String openid){
		String begin = year+"-"+month+"-01";
		String end = year+"-"+month+"-01";
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");  
	    try {
			Date date = sdf.parse(begin);
			Calendar calender = Calendar.getInstance();
	        calender.setTime(date);
	        begin = sdf.format(calender.getTime());
	        calender.add(Calendar.MONTH, 1);
	        end =  sdf.format(calender.getTime());
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return commonserviceProxy.getOrders(begin, end, openid);
	}
	
	@Override
	public String[] loadAllCard(String strCompId, String openId) {
		String card = commonserviceProxy.loadAllCard(strCompId, openId);
		if(StringUtils.isNotBlank(card)){
			return StringUtils.split(card, "@");
		}else{
			return new String[]{};
		}
	}
	
	@Override
	public Cardinfo loadCardInfobyOpenid(String strCompId, String openId, String strCardNo) {
		return commonserviceProxy.loadCardInfobyOpenid(strCompId, openId, strCardNo);
	}
	
	@Override
	public boolean changePassword(String openId, String cardno, String password){
		return commonserviceProxy.changePassword(openId, cardno, password);
	}
	
	@Override
	public List<Map<String, Object>> loadWxOrders(String openid, String catgory){
		ArrayOfAnyType2AnyTypeMap arrayMap = commonserviceProxy.loadWxOrders(openid, catgory);
		return ToListMap(arrayMap);
	}

	@Override
	public List<ActivateCard> loadAccount(String openid) {
		List<ActivateCard> resList = new ArrayList<ActivateCard>();
		List<Account> tmp = commonserviceProxy.loadAccount(openid).getAccount();
		for(Account t : tmp){
			ActivateCard res = new ActivateCard();
			res.setCard_id("prCjajnQ1iPwjJHEZ0i8DbHYZgdo");
			res.setMembership_number(t.getCode().getValue());
			res.setCode(t.getCode().getValue());
			res.setInit_balance(t.getBalance()==null?0:t.getBalance().floatValue());
			res.setInit_bonus(t.getBonus()==null?0:t.getBonus().floatValue());
			resList.add(res);
		}
		
		return resList;
	}
	
	public static void main(String[] args) {
		CommonService aCommonService = new CommonService();
		aCommonService.bindingCard("0391000019", "任捷", "13761811844", "orCjajg_JazaGkqIbNu2IgS4xjZQ");
	}

	@Override
	public amani.wechat.platform.services.model.Staffinfo loadStaffInfo(String staffNo) {
		Map temp = this.ToMap(commonserviceProxy.loadStaffInfoNo(staffNo));
		amani.wechat.platform.services.model.Staffinfo item=new amani.wechat.platform.services.model.Staffinfo();  
    	item.setStaffno((String)temp.get("staffno"));
    	item.setStaffopenid((String)temp.get("staffopenid"));
    	item.setStaffimageurl((String)temp.get("staffimageurl"));
    	item.setStaffname((String)temp.get("staffename"));
    	item.setDescription((String)temp.get("description"));
    	item.setCompno((String)temp.get("compno"));
    	item.setCompname((String)temp.get("compname"));
    	item.setXcoordinate((String)temp.get("xcoordinate"));
    	item.setYcoordinate((String)temp.get("ycoordinate"));
    	item.setStarnum((Integer)temp.get("starnum"));
       	//item.setPrice(Double.parseDouble(temp.get("price").toString()));
    	item.setCardId((String)temp.get("cardId"));
    	item.setCompaddress((String)temp.get("compaddress"));
    	item.setMobilephone((String)temp.get("mobilephone"));
    	item.setPosition((String)temp.get("position"));
		return item;
	}
	
	public boolean saveNointernalcardinfo(String cardvesting,String cardno,int cardtype,float cardfaceamt,int carduseflag,
			int entrytype,int cardstate,String usedate,String useinproject,String oldvalidate,String lastvalidate,String enabledate,int uespassward,String cardpassward,int createtype,int createcardtype,String openid){
		boolean result = commonserviceProxy.saveNointernalcardinfo( cardvesting, cardno, cardtype, cardfaceamt, carduseflag,
				 entrytype, cardstate, usedate, useinproject, oldvalidate, lastvalidate, enabledate, uespassward, cardpassward, createtype, createcardtype,openid);
		return result;
	}
	
	public boolean saveDnointernalcardinfo(String cardvesting,String cardno,float seqno,String ineritemno,float entrycount,
			float usecount,float lastcount, float entryamt ,float useamt,float lastamt,String costbillno, String entryremark){
		boolean result = commonserviceProxy.saveDnointernalcardinfo( cardvesting, cardno, seqno, ineritemno, entrycount,
				 usecount, lastcount, entryamt , useamt, lastamt, costbillno,  entryremark);
		return result;
	}
}
